import axios from "axios";
axios.defaults.headers["Content-Type"] = "application/json";
axios.defaults.headers.get["Content-Type"] =
    "application/x-www-form-urlencoded";
axios.defaults.withCredentials = true;
// 创建axios实例
axios.defaults.withCredentials = true;

const service = axios.create({
    // axios中请求配置有baseURL选项，表示请求URL公共部分
    baseURL: 'http://127.0.0.1:8081/',
    // 超时
    timeout: 100000,
    withCredentials:true
});
service.interceptors.request.use(
    (config) => {
        // let token = sessionStorage.getItem("BookPlatformToken");
        // token = JSON.parse(token);
        // if (token) {
        //     config.headers = config.headers || {};
        //     config.headers.Authorization = token || {};
        // }
        return config;
    },
    (err) => {
        return Promise.reject(err);
    }
);

export default service;